#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <string.h>
#include <fcntl.h>
#include "cyassl/ctaocrypt/sha.h"
// Get the size of the file by its file descriptor
/*unsigned long get_size_by_fd(int fd)
{
    struct stat statbuf;
    if(fstat(fd, &statbuf) < 0) exit(-1);
    return statbuf.st_size;
}*/

void print_hash(byte* hash) {
    int i;
    for(i=0; i <SHA_DIGEST_SIZE; i++) {
            printf("%02x",hash[i]);
    }
}
/*
int main(void)
{
	int file_descript;
	unsigned long file_size;
	char* file_buffer;


	file_descript = open("/home/ruhma/test.bin", O_RDONLY);
	if(file_descript < 0) exit(-1);

	file_size = get_size_by_fd(file_descript);
	printf("File size:\t%lu\n", file_size);

	file_buffer = mmap(0, file_size, PROT_READ, MAP_SHARED, file_descript, 0);

	char* icmetrics_basis="8t9y5";
	byte shaSum[SHA_DIGEST_SIZE];

	char* icm_rand;

	icm_rand = (char *)malloc(strlen(icmetrics_basis) + strlen(rng) +1);
	strcpy(icm_rand,icmetrics_basis);
	strcat(icm_rand,rng);

	Sha sha;
	InitSha(&sha);

	ShaUpdate(&sha, icm_rand, sizeof(icm_rand ));  // can be called again and again
	ShaFinal(&sha, shaSum);

	print_hash(shaSum);

	return 0;
}
*/
